<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>proxy</title>
</head>

<body>

</body>
<script>
    'use strict'
    // const target = {
    //     foo: 'fo',
    //     bar: 'bar'
    // }
    // let proxy = new Proxy(target, {
    //     get(target, key, receiver) {
    //         return Reflect.get(target, key, receiver)
    //     },
    //     set(target, key, val, receiver) {
    //         return Reflect.set(target, key, receiver)
    //     },
    //     deleteProperty(target, key) {
    //         // return Reflect.deleteProperty(target, key)
    //     }
    // })
    // proxy.name = 'proxy'
    // delete proxy.foo



    const obj = {
        get foo() {
            console.log(this)
            return this.bar
        }
    }
    const proxy = new Proxy(obj, {
        get(target, key, receiver) {
            if (key === 'bar') {
                return 'value-bar'
            }
            return Reflect.get(target, key,receiver)
        }
    })
    console.log(proxy.foo)
</script>

</html>